class DirectionalLight {

    constructor(lightIntensity, lightColor, lightPos, focalPoint, lightUp, hasShadowMap, gl) {
        this.mesh = Mesh.cube(setTransform(0, 0, 0, 0.2, 0.2, 0.2, 0));
        this.mat = new EmissiveMaterial(lightIntensity, lightColor);
        this.lightPos = lightPos;
        this.focalPoint = focalPoint;
        this.lightUp = lightUp

        this.hasShadowMap = hasShadowMap;
        this.fbo = new FBO(gl);
        if (!this.fbo) {
            console.log("无法设置帧缓冲区对象");
            return;
        }
    }

    CalcLightMVP(translate, scale) {

        let extent = 100;
        let dumyCamera = new THREE.OrthographicCamera(-extent,extent,extent,-extent,0.1,1000);
        dumyCamera.position.set(this.lightPos[0], this.lightPos[1], this.lightPos[2]);
        dumyCamera.lookAt(this.focalPoint[0], this.focalPoint[1], this.focalPoint[2]);
        dumyCamera.updateProjectionMatrix();
        dumyCamera.updateMatrixWorld();

        let projectionMatrix = dumyCamera.projectionMatrix;
        let viewMatrix = dumyCamera.matrixWorldInverse;
        let model_s = new THREE.Matrix4();
        model_s.makeScale(scale[0], scale[1], scale[2]);
        let model_t = new THREE.Matrix4();
        model_t.makeTranslation(translate[0], translate[1], translate[2]);
        let lightMVP =  new THREE.Matrix4();
        lightMVP.premultiply(model_s).premultiply(model_t).premultiply(viewMatrix).premultiply(projectionMatrix);
        return lightMVP.toArray();
    }
}
